package club.mzywucai.blog.file_system.service.impl;

import club.mzywucai.blog.file_system.mapper.CheckBoxMapper;
import club.mzywucai.blog.file_system.pojo.vo.KeyAndValueVo;
import club.mzywucai.blog.file_system.service.CheckBoxService;
import club.mzywucai.blog.file_system.util.MyStringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author mzywucai
 * @Description
 * @date 2019/1/30
 */
@Service
public class CheckBoxServiceImpl implements CheckBoxService {
    @Autowired
    CheckBoxMapper checkBoxMapper;

    @Override
    public List<KeyAndValueVo> getFileCategoryLevelOne() {
        return checkBoxMapper.getFileCategoryLevelOne();
    }

    @Override
    public List<KeyAndValueVo> getFileCategoryLevelTwo(String parentId) {
        boolean res = MyStringUtil.isNumericByJavaDefault(parentId);
        if (res) {
            int parentIdParse = Integer.parseInt(parentId);
            return checkBoxMapper.getFileCategoryLevelTwo(parentIdParse);
        }
        return null;
    }
}
